using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace com.yoozoo.gta.Art.RpgScene
{
    public class SetMainCharacterPos : MonoBehaviour
    {
        public int idxPos = 0;
        public static Transform MainCharacter;
        private int _pid;
        private static readonly int m_mainCharacterPos = Shader.PropertyToID("_WorldMainCharacterPos");
        private static readonly int m_secondCharacterPos = Shader.PropertyToID("_WorldSecondCharacterPos");
        private static readonly int m_mainCharacherDir = Shader.PropertyToID("_WorldMainCharacterDir");

        void Update()
        {
            try
            {
                _pid = idxPos == 0 ? m_mainCharacterPos : m_secondCharacterPos;
                MainCharacter = this.transform;
                Shader.SetGlobalVector(_pid, transform.position);
                //UnityEngine.Debug.LogError($"{transform.name}__{transform.position}");
                if (idxPos == 0)
                {
                    Shader.SetGlobalVector(m_mainCharacherDir, transform.forward);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"{e}");
                throw;
            }
        }
    }
}
